#include "stdafx.h"
#include "pywindow.h"
#include "skins.h"

#include <gtl/script/pyscript.h>

namespace gtl
{

namespace skins
{

skins* pywindow::m_skins = NULL;

pywindow::pywindow()
{

}

void pywindow::close(const std::string& id)
{

}

void pywindow::show(const std::string& id)
{

}

void pywindow::move(const std::string& id, int x, int y, int width, int height)
{

}

void pywindow::visible(const std::string& id, bool value)
{

}

void pywindow::alert(const std::string& text, const std::string& caption)
{
	HWND hWnd = NULL;
	std::string strCaption = caption;
	char szCaption[MAX_PATH] = {0};
	if(m_skins != NULL && m_skins->get_main_wnd() != NULL)
	{
		hWnd = m_skins->get_main_wnd()->m_hWnd;
		if(hWnd != NULL && caption.empty())
		{
			::GetWindowTextA(hWnd, szCaption, MAX_PATH);
			strCaption = szCaption;
		}
	}

	::MessageBoxA(hWnd, text.c_str(), strCaption.c_str(), MB_OK);
}

unsigned long pywindow::hwnd(const std::string& id)
{
	return (unsigned long)get_hwnd(id);
}

void pywindow::rect(const std::string& id)
{

}

int pywindow::width(const std::string& id)
{
	return 0;
}

int pywindow::height(const std::string& id)
{
	return 0;
}

void pywindow::position(const std::string& id)
{

}

void pywindow::set_skins_ptr(skins* skinsptr)
{
	m_skins = skinsptr;
}

HWND pywindow::get_hwnd(const std::string& id)
{
	if(m_skins == NULL)
		return NULL;

#ifdef UNICODE
	wnd* wnd_ptr = m_skins->get_ctrl<wnd>(gtl::str(id).trans());
#else
	wnd* wnd_ptr = m_skins->get_ctrl<wnd>(id.c_str());
#endif
	if(wnd_ptr == NULL)
		return NULL;

	return wnd_ptr->m_hWnd;
}

} // end of namespace skins

} // end of namespace gtl
